/*
 * Copyright 2018 JDCLOUD.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * JDCloud IAS
 * 京东云联合登陆
 *
 * OpenAPI spec version: v1
 * Contact: 
 *
 * NOTE: This class is auto generated by the jdcloud code generator program.
 */


using JDCloudSDK.Core.Auth;
using JDCloudSDK.Core.Client;
using JDCloudSDK.Core.Http;
using JDCloudSDK.Ias.Apis;
using JDCloudSDK.Ias.Model;
using System;
using System.Collections.Generic;
using System.Text;
#if NET40||NET35
#else
using System.Threading.Tasks;
#endif

namespace JDCloudSDK.Ias.Client
{
    /// <summary>
    ///  JDCloud IAS
    ///  京东云联合登陆
    ///  Ias Api 客户端
    ///</summary>
    public class IasClient : JdcloudClient
    {

        /// <summary>
        ///  默认私有构造函数
        /// </summary>
        private IasClient()
        {

        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="credentialsProvider">认证信息</param>
        /// <param name="httpRequestConfig">http 客户端配置信息</param>
        /// <param name="environment">sdk 环境配置信息</param>
        public IasClient(CredentialsProvider credentialsProvider, HttpRequestConfig httpRequestConfig,SDKEnvironment environment)
        {
            this.httpRequestConfig = httpRequestConfig;
            this.credentialsProvider = credentialsProvider;
            this.environment = environment;
        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="httpRequestConfig">http 客户端配置信息</param>
        /// <param name="credentialsProvider">认证信息</param>
        public IasClient(CredentialsProvider credentialsProvider,HttpRequestConfig httpRequestConfig)
        {
            this.httpRequestConfig = httpRequestConfig;
            this.credentialsProvider = credentialsProvider;
        }

        /// <summary>
        /// 默认构造函数，
        /// 注意如果使用此方法 httpRequestConfig 使用的http 请求 schema 为Https
        /// </summary>
        /// <param name="credentialsProvider">认证信息</param>
        public IasClient(CredentialsProvider credentialsProvider)
        {
            this.credentialsProvider = credentialsProvider;
        }

        /// <summary>
        ///  版本号 1.0.9
        ///</summary>
        public const string ClientVersion = "1.0.9";

        private const string apiVersion = "v1";
        private const string userAgentPrefix = "JdcloudSdkDotNet";
        private const string defaultEndpoint = "ias.jdcloud-api.com";
        private const string serviceName = "ias";
        private const string userAgent = userAgentPrefix + "/" + ClientVersion + " " + serviceName + "/" + apiVersion;


        private SDKEnvironment environment = new SDKEnvironment(defaultEndpoint);
        private CredentialsProvider credentialsProvider;
        private HttpRequestConfig httpRequestConfig;

        /// <summary>
        ///  获取证书信息
        ///</summary>
        public override CredentialsProvider CredentialsProvider   { get { return credentialsProvider; } }

        /// <summary>
        ///  获取http 客户端配置信息
        ///</summary>
        public override HttpRequestConfig HttpRequestConfig { get { return httpRequestConfig; } }

        /// <summary>
        ///  获取sdk环境配置信息
        ///</summary>
        public override SDKEnvironment SDKEnvironment { get { return environment; } }

        /// <summary>
        ///  获取用户自定义浏览器识别字符串
        ///</summary>
        public override string UserAgent { get { return userAgent; } }

        /// <summary>
        ///  获取服务名称
        ///</summary>
        public override string ServiceName { get { return serviceName; } }

        /// <summary>
        ///  获取版本号
        ///</summary>
        public override string Version { get { return apiVersion; } }



#if NET40||NET35
        /// <summary>
        ///  获取应用
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetAppResponse GetApp(GetAppRequest request) {
            return  new GetAppExecutor().Client(this).Execute<GetAppResponse, GetAppResult, GetAppRequest>(request);
        }
#else
        /// <summary>
        ///  获取应用
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetAppResponse> GetApp(GetAppRequest request) {
            return await new GetAppExecutor().Client(this).Execute<GetAppResponse, GetAppResult, GetAppRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  运营后台获取应用状态
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public StateResponse State(StateRequest request) {
            return  new StateExecutor().Client(this).Execute<StateResponse, StateResult, StateRequest>(request);
        }
#else
        /// <summary>
        ///  运营后台获取应用状态
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<StateResponse> State(StateRequest request) {
            return await new StateExecutor().Client(this).Execute<StateResponse, StateResult, StateRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  创建应用
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public CreateAppResponse CreateApp(CreateAppRequest request) {
            return  new CreateAppExecutor().Client(this).Execute<CreateAppResponse, CreateAppResult, CreateAppRequest>(request);
        }
#else
        /// <summary>
        ///  创建应用
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<CreateAppResponse> CreateApp(CreateAppRequest request) {
            return await new CreateAppExecutor().Client(this).Execute<CreateAppResponse, CreateAppResult, CreateAppRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  获取账户下所有应用
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetAppsResponse GetApps(GetAppsRequest request) {
            return  new GetAppsExecutor().Client(this).Execute<GetAppsResponse, GetAppsResult, GetAppsRequest>(request);
        }
#else
        /// <summary>
        ///  获取账户下所有应用
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetAppsResponse> GetApps(GetAppsRequest request) {
            return await new GetAppsExecutor().Client(this).Execute<GetAppsResponse, GetAppsResult, GetAppsRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  更新应用（只传需要变更的参数，不传的参数不会更新）
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public UpdateAppResponse UpdateApp(UpdateAppRequest request) {
            return  new UpdateAppExecutor().Client(this).Execute<UpdateAppResponse, UpdateAppResult, UpdateAppRequest>(request);
        }
#else
        /// <summary>
        ///  更新应用（只传需要变更的参数，不传的参数不会更新）
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<UpdateAppResponse> UpdateApp(UpdateAppRequest request) {
            return await new UpdateAppExecutor().Client(this).Execute<UpdateAppResponse, UpdateAppResult, UpdateAppRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  运营后台获取应用详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public AppDetailResponse AppDetail(AppDetailRequest request) {
            return  new AppDetailExecutor().Client(this).Execute<AppDetailResponse, AppDetailResult, AppDetailRequest>(request);
        }
#else
        /// <summary>
        ///  运营后台获取应用详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<AppDetailResponse> AppDetail(AppDetailRequest request) {
            return await new AppDetailExecutor().Client(this).Execute<AppDetailResponse, AppDetailResult, AppDetailRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  删除应用
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public DeleteAppResponse DeleteApp(DeleteAppRequest request) {
            return  new DeleteAppExecutor().Client(this).Execute<DeleteAppResponse, DeleteAppResult, DeleteAppRequest>(request);
        }
#else
        /// <summary>
        ///  删除应用
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<DeleteAppResponse> DeleteApp(DeleteAppRequest request) {
            return await new DeleteAppExecutor().Client(this).Execute<DeleteAppResponse, DeleteAppResult, DeleteAppRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  运营后台查询app
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public AppsResponse Apps(AppsRequest request) {
            return  new AppsExecutor().Client(this).Execute<AppsResponse, AppsResult, AppsRequest>(request);
        }
#else
        /// <summary>
        ///  运营后台查询app
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<AppsResponse> Apps(AppsRequest request) {
            return await new AppsExecutor().Client(this).Execute<AppsResponse, AppsResult, AppsRequest>(request).ConfigureAwait(false);
        }
#endif

            /// <summary>
            ///  默认IasClient 构造器 接口
            ///</summary>
            public interface Builder
            {

                /// <summary>
                /// 设置认证信息参数
                /// </summary>
                /// <param name="provider">认证信息提供对象</param>
                /// <returns>iasClient 构造器</returns>
                Builder CredentialsProvider(CredentialsProvider provider);

                /// <summary>
                /// 设置请求环境参数
                /// </summary>
                /// <param name="environment">环境参数信息</param>
                /// <returns>iasClient 构造器</returns>
                Builder Environment(Core.Client.SDKEnvironment environment);

                /// <summary>
                /// http 请求配置信息
                /// </summary>
                /// <param name="config">http 请求配置信息</param>
                /// <returns>iasClient 构造器</returns>
                Builder HttpRequestConfig(HttpRequestConfig config);

                /// <summary>
                ///  构造IasClient 对象
                ///</summary>
                IasClient Build();
            }

            /// <summary>
            ///  默认IasClient 构造器
            ///</summary>
            public class DefaultBuilder : Builder
            {
                /// <summary>
                ///  IasClient service client
                /// </summary>
                private  IasClient iasClient;

                /// <summary>
                ///  默认IasClient 构造器构造对象
                ///</summary>
                public DefaultBuilder()
                {
                    iasClient = new IasClient();
                }

                /// <summary>
                ///  构造IasClient 对象
                ///</summary>
                public IasClient Build()
                {
                    if (iasClient.CredentialsProvider == null)
                    {
                        //if credentialsProvider not set, try load jdcloud global default  credentials provider
                        iasClient.credentialsProvider = JdCloud.DefaultInstance.GetCredentialsProvider();
                        if (iasClient.credentialsProvider == null)
                        {
                            throw new ArgumentNullException("IasClient build error: jdcloud credentials provider not set");
                        }
                    }
                    if (iasClient.HttpRequestConfig == null)
                    {
                        iasClient.httpRequestConfig = JdCloud.DefaultInstance.GetHttpRequestConfig();
                        if (iasClient.httpRequestConfig == null)
                        {
                        throw new ArgumentNullException("IasClient build error: http request config not set");
                        }
                    }
                    return iasClient;
                }

                /// <summary>
                /// 设置认证信息参数
                /// </summary>
                /// <param name="provider">认证信息提供对象</param>
                /// <returns>iasClient 构造器</returns>
                public Builder CredentialsProvider(CredentialsProvider provider)
                {
                    iasClient.credentialsProvider = provider;
                    return this;
                }

                /// <summary>
                /// 设置请求环境参数
                /// </summary>
                /// <param name="environment">环境参数信息</param>
                /// <returns>iasClient 构造器</returns>
                public Builder Environment(SDKEnvironment environment)
                {
                    iasClient.environment = environment;
                    return this;
                }

                /// <summary>
                /// http 请求配置信息
                /// </summary>
                /// <param name="config">http 请求配置信息</param>
                /// <returns>iasClient 构造器</returns>
                public Builder HttpRequestConfig(HttpRequestConfig config)
                {
                    iasClient.httpRequestConfig = config;
                    return this;
                }
            }
    }
}
